<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>GetFileAttributes</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<font face="Arial" size="2"><p align="center"><b><font size="4">GetFileAttributes()</font></b></p>
<p><b>语法</b></p><blockquote>

Attributes = <font color="#006666"><b>GetFileAttributes</b></font>(Filename$)</blockquote>

</blockquote>
<b>概要</b><br><blockquote>



Returns the attributes of the given file. 

 

</blockquote><p><b>参数</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>Filename$</i></td>
<td width="90%"> 
 
The file to read the attributes from. This can also specify the name of a directory. 

 

</td></tr>
</table>
</blockquote><p><b>返回值</b></p><blockquote>



Returns the attributes of the file. If the file does not exist or the attributes cannot be read, 
the result is the value -1. 
<br>
<br>
On Windows, Attributes is a combination of the following values: 
 
<pre><font face="Courier New, Courier, mono"size="2">  <font color="#924B72">#PB_FileSystem_Hidden</font>    : File is hidden
  <font color="#924B72">#PB_FileSystem_Archive</font>   : File has been changed and not archived since the last time
  <font color="#924B72">#PB_FileSystem_Compressed</font>: File is compressed
  <font color="#924B72">#PB_FileSystem_Normal</font>    : Normal attributes
  <font color="#924B72">#PB_FileSystem_ReadOnly</font>  : File is in read-only mode
  <font color="#924B72">#PB_FileSystem_System</font>    : File is a system file
</font></pre>



On Linux or MacOSX, Attributes is a combination of these values: 
 
<pre><font face="Courier New, Courier, mono"size="2">  <font color="#924B72">#PB_FileSystem_Link</font>      : The file is a symbolic link
  <font color="#924B72">#PB_FileSystem_ReadUser</font>  : Access flags for the owning user
  <font color="#924B72">#PB_FileSystem_WriteUser</font>
  <font color="#924B72">#PB_FileSystem_ExecUser</font>
  <font color="#924B72">#PB_FileSystem_ReadGroup</font> : Access flags for the owning user's group
  <font color="#924B72">#PB_FileSystem_WriteGroup</font>
  <font color="#924B72">#PB_FileSystem_ExecGroup</font>
  <font color="#924B72">#PB_FileSystem_ReadAll</font>   : Access flags for all other users
  <font color="#924B72">#PB_FileSystem_WriteAll</font>
  <font color="#924B72">#PB_FileSystem_ExecAll</font>
</font></pre>

</blockquote><p><b>Remarks</b></p><blockquote>



To check if one attribute is actually set, just use the '&amp;' (binary AND) and the attribute constant value: 
 
<pre><font face="Courier New, Courier, mono"size="2">  FileAttributes =<font color="#006666"> GetFileAttributes</font>("C:\Text.txt")
  <b><font color="#006666">If</font></b> FileAttributes &amp; <font color="#924B72">#PB_FileSystem_Hidden</font>
    <b><font color="#006666">Debug</font></b> "This file is hidden !"
  <b><font color="#006666">EndIf</font></b>
</font></pre>

</blockquote><p><b>示例</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  Value =<font color="#006666"> GetFileAttributes</font>("c:\autoexec.bat") 
  
  <b><font color="#006666">If</font></b> Value = -1 
    <b><font color="#006666">Debug</font></b> "Error reading file attributes!"
  <b><font color="#006666">Else</font></b> 
    <b><font color="#006666">If</font></b> Value &amp; <font color="#924B72">#PB_FileSystem_Hidden</font>     : txt$ + "H" : <b><font color="#006666">Else</font></b> : txt$+"-" : <b><font color="#006666">EndIf</font></b> 
    <b><font color="#006666">If</font></b> Value &amp; <font color="#924B72">#PB_FileSystem_Archive</font>    : txt$ + "A" : <b><font color="#006666">Else</font></b> : txt$+"-" : <b><font color="#006666">EndIf</font></b> 
    <b><font color="#006666">If</font></b> Value &amp; <font color="#924B72">#PB_FileSystem_Compressed</font> : txt$ + "C" : <b><font color="#006666">Else</font></b> : txt$+"-" : <b><font color="#006666">EndIf</font></b> 
    <b><font color="#006666">If</font></b> Value &amp; <font color="#924B72">#PB_FileSystem_Normal</font>     : txt$ + "N" : <b><font color="#006666">Else</font></b> : txt$+"-" : <b><font color="#006666">EndIf</font></b> 
    <b><font color="#006666">If</font></b> Value &amp; <font color="#924B72">#PB_FileSystem_ReadOnly</font>   : txt$ + "R" : <b><font color="#006666">Else</font></b> : txt$+"-" : <b><font color="#006666">EndIf</font></b> 
    <b><font color="#006666">If</font></b> Value &amp; <font color="#924B72">#PB_FileSystem_System</font>     : txt$ + "S" : <b><font color="#006666">Else</font></b> : txt$+"-" : <b><font color="#006666">EndIf</font></b> 
    <b><font color="#006666">Debug</font></b> txt$ 
  <b><font color="#006666">EndIf</font></b>
</font></pre>

</blockquote><p><b>参阅</b></p><blockquote>

<a href="setfileattributes.html">SetFileAttributes()</a>, <a href="directoryentryattributes.html">DirectoryEntryAttributes()</a> 

</Blockquote><p><b>已支持操作系统 </b><Blockquote>所有</Blockquote></p><center>&lt;- <a href=getextensionpart.html>GetExtensionPart()</a> - <a href=index.html>FileSystem Index</a> - <a href=getfiledate.html>GetFileDate()</a> -&gt;



</body></html>